/**
 * File name: DummyPoint.java Author: Willard Wang Create date: Aug 24, 2013
 */
package edu.sjtu.se.prophet.cluster;

/**
 * @author deathspeeder
 * 
 */
public class PointWithId implements Point {
    protected String id;
    protected Cluster cluster;

    public PointWithId(String id) {
        this.id = id;
    }

    public String toString() {
        return "Point" + id;
    }

    public int hashCode() {
        return id.hashCode();
    }

    public boolean equals(Object obj) {
        return obj == this;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    /*
     * (non-Javadoc)
     * 
     * @see edu.sjtu.se.prophet.cluster.Point#getCluster()
     */
    @Override
    public Cluster getCluster() {
        return cluster;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.cluster.Point#setCluster(edu.sjtu.se.prophet.cluster
     * .Cluster)
     */
    @Override
    public void setCluster(Cluster cluster) {
        this.cluster = cluster;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.cluster.Point#moveTo(edu.sjtu.se.prophet.cluster.
     * Cluster)
     */
    @Override
    public void moveTo(Cluster cluster) {
        if (this.cluster != null)
            this.cluster.removePoint(this);
        cluster.addPoint(this);
    }

}
